<%@ page language="java" pageEncoding="utf-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
${aier_doctype}
<html <s:property value="aier_html_xmlns" escape="false"/>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>${aier_title}</title>
<meta content="${aier_keywords}" name="keywords">
<meta content="${aier_description}" name="description">
<link href="${aier_css_url}jc/chosen.css" rel="stylesheet">
<link rel="stylesheet" href="${aier_css_url}jq/jq.css" />
<link rel="stylesheet" href="${aier_css_url}${aier_jqui_css}ui.css" />
<link rel="stylesheet" href="${aier_css_url}comm/text.css" />
<link rel="stylesheet" href="${aier_css_url}b.css" />
<link rel="stylesheet" href="${aier_css_url}social/module/jq-msg.css" />
<link rel="stylesheet" href="${aier_css_url}comm/fb.css" />

<script type="text/javascript" src="${aier_js_url}j.js"></script>
<script type="text/javascript" src="${aier_js_url}b.js"></script>
<script type="text/javascript" src="${aier_js_url}jp/hh/ui.js"></script>
<script type="text/javascript" src="${aier_js_url}jp/msg.js"></script>
<script type="text/javascript" src="${aier_js_url}lib/block.js"></script>
<script type="text/javascript" src="${aier_js_url}lib/arrayList.js"></script>
<script type="text/javascript" src="${aier_js_url}jc/cj.js"></script>
<script type="text/javascript" src="${aier_js_url}jq/jq.js"></script>
<script type="text/javascript" src="${aier_js_url}jq/cn.js"></script>
<script type="text/javascript" src="${aier_js_url}comm/text.js"></script>
<title>意见反馈</title>
</head>
<script type="text/javascript">
	$(document)
			.ready(
					function() {
						$("#feedbackinfo")
								.jqGrid(
										{
											url : '${aier_url}commonjs/feedback_searchFeedback${aier_suffix}',
											datatype : "json",
											mtype : 'GET',
											height : '230',
											width : '960',
											colNames : [ '标题', '日期', '跟单员',
													'结果', '评分', '查阅', '状态',
													'编号', '内容', 'uid' ],
											colModel : [ {
												name : 'title',
												index : 'title',
												width : 120,
												align : 'center'
											}, {
												name : 'cdate',
												index : 'cdate',
												width : 100,
												align : 'center'
											}, {
												name : 'name',
												index : 'name',
												width : 80,
												align : 'center'
											}, {
												name : 'stateStr',
												index : 'stateStr',
												width : 80,
												align : 'center'
											}, {
												name : 'score',
												index : 'score',
												width : 80,
												align : 'center'
											}, {
												name : 'revoked',
												index : 'revoked',
												width : 80,
												align : 'center',
												sortable : false
											}, {
												name : 'state',
												index : 'state',
												hidden : true
											}, {
												name : 'fbid',
												index : 'fbid',
												hidden : true
											}, {
												name : 'content',
												index : 'content',
												hidden : true
											}, {
												name : 'uid',
												index : 'uid',
												hidden : true
											}, ],
											//autowidth:true,
											jsonReader : {
												root : "fbList",
												page : "page",
												total : "page_count",
												records : "count",
												repeatitems : false
											},
											pager : jQuery("#feedbackpage"),
											prmNames : {
												page : "page",
												sort : "sort"
											},
											rowNum : 10,
											//rowList: [10, 20, 30],
											sortname : 'cdate',
											hidegrid : false,
											sortorder : 'desc',
											viewrecords : true,
											caption : '意见反馈',
											gridComplete : function() {
												var ids = jQuery(
														"#feedbackinfo")
														.jqGrid('getDataIDs');
												for ( var i = 0; i < ids.length; i++) {
													var id = ids[i];
													var sc;
													var score = jQuery(
															"#feedbackinfo")
															.jqGrid(
																	'getRowData',
																	id).score;
													var state = jQuery(
															"#feedbackinfo")
															.jqGrid(
																	'getRowData',
																	id).state;
													if (score == -1
															&& state == 2) {
														sc = "<a href='javascript:;' class='jqtrow' onclick='addScore("
																+ id
																+ ")'>评分</a>";
													} else if (score == -1
															&& state == 1) {
														sc = "<a href='javascript:;' class='jqtrow'>--</a>";
													} else {
														sc = score;
													}
													var cdateStr = jQuery(
															"#feedbackinfo")
															.jqGrid(
																	'getRowData',
																	id).cdate;
													if (!isnull(cdateStr)) {
														cdateStr = cdateStr
																.split(".")[0];
														cdateStr = cdateStr
																.split("T")[0]
																+ " "
																+ cdateStr
																		.split("T")[1];
														;
													}
													var re = "<a href='javascript:;' class='jqtrow' onclick='optionManage("
															+ id + ")'>查看</a>";
													jQuery("#feedbackinfo")
															.jqGrid(
																	'setRowData',
																	ids[i],
																	{
																		revoked : re,
																		score : sc,
																		cdate : cdateStr
																	});
												}
											}
										}).navGrid("#feedbackpage", {
									edit : false,
									add : false,
									del : false,
									search : false
								});
					});
</script>
<body>
	<div id="tabs">
		<ul>
			<li><a href="#tabs-1">意见反馈</a>
			</li>
		</ul>
		<div id="tabs-1" style="height: 500px;">
			<div class="d_content">
				<button onclick="add()" style="margin-left: 660px;"
					class="b_maSel ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only"
					role="button" aria-disabled="false">
					<span class="ui-button-text">我有意见</span>
				</button>
				<!-- 表格 -->
				<div style="margin-left: 0px;*margin-left: -180px;margin-top: 0px;">
					<table id="feedbackinfo"></table>
					<div id="feedbackpage"></div>
				</div>
			</div>

			<!-- 评分的弹出层 -->
			<div id="commitScore" title="">
				<div class="d_scnOut">
					<div>
						<label>请给本次处理结果给个评分:</label>
					</div>
					<div>
						<input name="score" type="radio" value="0">0 <input
							name="score" type="radio" value="1">1 <input name="score"
							type="radio" value="2">2 <input name="score" type="radio"
							value="3">3 <input name="score" type="radio" value="4">4
						<input name="score" type="radio" value="5" checked="checked">5
					</div>
				</div>

				<button id="b_siUpdate"
					class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only"
					role="button" aria-disabled="false" style="left: 100px; top: 50px;"
					onclick="commitScore();">
					<span class="ui-button-text">提交评分</span>
				</button>
			</div>

			<!-- 弹出层 -->
			<div id="feedback_add" style="display: none;" title="意见反馈">
				<div style="*margin-left: -100px;">
					<div class="dv1_main">
						<div class="dv1_name" style="*margin-left: -200px;">标题</div>
						<div class="dv1_val">
							<input id="title" type="text" />
						</div>
					</div>
					<div class="dv1_main">
						<div class="dv1_name" style="*margin-left: -200px;">内容</div>
						<div class="dv1_val">
							<textarea id="content" rows="5" cols="30"></textarea>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</body>
<script type="text/javascript">
	$("#tabs").tabs();
	var fbid;
	// 弹出层
	$(function() {
		$("#commitScore").dialog({
			//背景变暗
			modal : true,
			autoOpen : false,
			show : "blind",
			//hide : "explode",
			width : "300",
			height : "200"
		});
	});

	function add() {
		$("#feedback_add")
				.dialog(
						{
							modal : true,
							resizable : false,
							height : 270,
							width : 400,
							buttons : {
								"提交意见" : function() {

									var title = $("#title");
									var titleVal = title.val();
									if (isnull(titleVal)
											|| titleVal.length > 20) {
										title.addClass("ui-state-error");
										$().message("标题字符长度为1-20个字符!");
										title.focus();
										return;
									} else {
										title.removeClass("ui-state-error");
									}
									var content = $("#content");
									var contentVal = content.val();
									if (isnull(contentVal)
											|| contentVal.length > 200) {
										content.addClass("ui-state-error");
										$().message("意见内容为1-200个字符!");
										content.focus();
										return;
									} else {
										content.removeClass("ui-state-error");
									}
									var fun = function(data) {
										if (1 == data.s) {
											$("#title").val("");
											$("#content").val("");
											$("#title").focus();
											$().message("添加成功,您可以继续添加!");
											$("#feedbackinfo").trigger(
													"reloadGrid");
										} else {
											$().message("添加失败,请稍后再试!");
										}
									};
									exeAjax(
											ajaxUrl("${aier_url}commonjs/feedback_commitAdvice${aier_suffix}"),
											fun, {
												"title" : titleVal,
												"content" : contentVal
											});
								}
							}
						});
	}

	function addScore(id) {
		fbid = jQuery("#feedbackinfo").jqGrid('getRowData', id).fbid;
		$("#commitScore").dialog("open");
	}

	function commitScore() {
		var score = document.getElementsByName("score");
		var scoreValue;
		for ( var i = 0; i < score.length; i++) {
			if (score[i].checked) {
				scoreValue = score[i].value;
				break;
			}
		}
		var fun = function(data) {
			if (data.s == 1) {
				$().message("评分成功");
				$("#commitScore").dialog("close");
				$("#feedbackinfo").trigger("reloadGrid");
			} else {
				$().message("评分失败");
			}
		};

		exeAjax(
				ajaxUrl("${aier_url}commonjs/feedback_commitScore${aier_suffix}"),
				fun, {
					"fbid" : fbid,
					"score" : scoreValue
				});
	}

	function optionManage(id) {
		var fbid = jQuery("#feedbackinfo").jqGrid('getRowData', id).fbid;
		window.location.href = "${aier_url}common/feedback_feedbackDetail${aier_suffix}?fbid="
				+ fbid;
	}
</script>
</html>